/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.mnt.domain

import cn.hutool.core.bean.BeanUtil
import cn.hutool.core.bean.copier.CopyOptions
import com.fasterxml.jackson.annotation.JsonTypeName
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.persistence.*
import me.zhengjie.common.base.BaseEntity
import org.springframework.data.redis.core.RedisHash

import java.io.Serializable

/**
 * @author zhanghouying
 * @date 2019-08-24
 */
@Entity
@Table(name = "mnt_app")
@JsonTypeName("App")
@RedisHash("App")
data class App (
    @Id
    @Column(name = "app_id")
    @Schema(description = "ID", required = true, hidden=true)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null,

    @Schema(description = "名称")
    var name: String? = null,

    @Schema(description = "端口")
    var port: Int = 0,

    @Schema(description = "上传路径")
    var uploadPath: String? = null,

    @Schema(description = "部署路径")
    var deployPath: String? = null,

    @Schema(description = "备份路径")
    var backupPath: String? = null,

    @Schema(description = "启动脚本")
    var startScript: String? = null,

    @Schema(description = "部署脚本")
    var deployScript: String? = null

): BaseEntity() {
    fun copy(source: App?) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true))
    }
}